package com.captjack.fastdfs.configuration;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Properties;

/**
 * @author Capt Jack
 * @date 2018/6/28
 */
@Configuration
public class FastDistributeFileSystemConfiguration {

    @Value("${fastdfs.tracker_servers}")
    private String trackerServers;

    @Value("${fastdfs.connect_timeout_in_seconds}")
    private String connectTimeoutInSeconds;

    @Value("${fastdfs.network_timeout_in_seconds}")
    private String networkTimeoutInSeconds;

    @Value("${fastdfs.charset}")
    private String charset;

    @Value("${fastdfs.http_anti_steal_token}")
    private String httpAntiStealToken;

    @Value("${fastdfs.http_secret_key}")
    private String httpSecretKey;

    @Value("${fastdfs.http_tracker_http_port}")
    private String httpTrackerHttpPort;

    /**
     * @return fastdfs配置文件
     */
    @Bean(name = "fastDistributeFileSystemConfigurationProperties")
    Properties fastDistributeFileSystemConfigurationProperties() {
        Properties properties = new Properties();
        properties.put("fastdfs.tracker_servers", trackerServers);
        properties.put("fastdfs.connect_timeout_in_seconds", connectTimeoutInSeconds);
        properties.put("fastdfs.network_timeout_in_seconds", networkTimeoutInSeconds);
        properties.put("fastdfs.charset", charset);
        properties.put("fastdfs.http_anti_steal_token", httpAntiStealToken);
        properties.put("fastdfs.http_secret_key", httpSecretKey);
        properties.put("fastdfs.http_tracker_http_port", httpTrackerHttpPort);
        return properties;
    }

}
